from openai import OpenAI

client = OpenAI(
    api_key="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"
)

response = client.chat.completions.create(
    model="gpt-4o",  # 也可以用 gpt-4.1, gpt-4.5, o3
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a one-sentence bedtime story about a unicorn."},
    ],
    max_tokens=500,
)

print(response.choices[0].message.content)

# connection error
